import logging
import time


class RequestTimeMiddleware:
    def __init__(self, get_response) -> None:
        self.get_response = get_response

    def __call__(self, request):  # noqa: ANN204
        timestamp = time.monotonic()
        logging.basicConfig(format="%(message)s", level=logging.INFO)
        response = self.get_response(request)
        time_var = f"{time.monotonic() - timestamp:.3f}"
        path = f"{request.path}"
        logging.info("Продолжительность запроса %s - %s", path, time_var)
        return response
